#include "Comm.hpp"

//这边是接受信息,文件的创建和删除都在这边
int main()
{
    
    bool n = creatFifo(NAMED_PIPE);
    assert(n);
    (void)n;
    //开始从命名管道读数据
    int rfd = open(NAMED_PIPE,O_RDONLY);
    if(rfd<0) exit(-1);
    char buffer[1024];
    while(true)
    {
        ssize_t s = read(rfd,buffer,sizeof(buffer)-1);
        if(s>0)
        {
            buffer[s]=0;
            cout<<"client->server# "<<buffer<<endl;
        }
        else if(s==0)
        {
            cout<<"client quit,me too!"<<endl;
            break;
        }
        else{
            cout<<"err string:"<<strerror(errno)<<endl;
            break;
        }

    }
    remove(NAMED_PIPE);
    return 0;
}